package com.tui.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class TimeUtils {
	/**
	 * 格式化时�?	 * @param date
	 * @return
	 */
	public static String getTimeStr(Date date) {
		if(date==null)
		{
			return "unKown";
		}
		Date today = new Date();
		long interval = today.getTime() - date.getTime();
		today.setHours(23);
		today.setMinutes(59);
		today.setSeconds(59);
		boolean isSameDay = (interval / 86400000) == 0 ? true : false;
		if (isSameDay) {
			if(interval<60*1000){
				return (interval/1000)+" sec ago";
			}else if(interval<60*60*1000){
				return (interval/(60*1000))+" min ago";
			}else{
				return (interval/(60*60*1000))+" hour ago";
			}
		} else {
			SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd hh:mm",
					Locale.CHINA);
			return dateFormat.format(date);
		}
	}

	public static String getSimpleTimeStr(Date date)
	{
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm",
				Locale.CHINA);
		return dateFormat.format(date);
	}
	
	public static String getCurDate()
	{
		//获取当前日期
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
		String strDate = df.format(new Date());
		return strDate;
	}
	
	public static String getCurDateHHMM()
	{
		//获取当前日期
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss", Locale.CHINA);
		String strDate = df.format(new Date());
		return strDate;
	}
	
	
	public static String getCurDateS()
	{
		//获取当前日期
		SimpleDateFormat df = new SimpleDateFormat("MM-dd HH:mm", Locale.CHINA);
		String strDate = df.format(new Date());
		//long curDate = Long.parseLong(strDate);
		return strDate;
	}
	
	public static String getCurDateSM()
	{
		//获取当前日期
		SimpleDateFormat df = new SimpleDateFormat("HH:mm", Locale.CHINA);
		String strDate = df.format(new Date());
		return strDate;
	}
	
	public static String getDateBylastModified(Long iTime)
	{
		//获取当前日期
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
		String strDate = df.format(new Date(iTime));
		return strDate;
	}
	
	/**
	 * _yyyy_MMdd_HHmms 格式显示时间;
	 * @return
	 */
	public static String getCurTime()
	{
		//获取当前日期
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss", Locale.CHINA);
		String strDate = df.format(new Date());
		return strDate;
	}
	
	public static String getCurWeekDay()
	{
		//获取当前日期
		SimpleDateFormat df = new SimpleDateFormat("E", Locale.CHINA);
		String strDate = df.format(new Date());
		return strDate;
	}

}
